﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HostAssistantCore
{
	/// <summary>
	/// IIS操作接口
	/// </summary>
	public interface IUtil
	{
		/// <summary>
		/// 创建站点
		/// </summary>
		/// <param name="siteName">站点名，必填</param>
		/// <param name="httpPort">http端口，IIS6下必填</param>
		/// <param name="httpsPort">https端口</param>
		/// <param name="sslHash">ssl证书hash，指定httpsPort时必填</param>
		/// <param name="physicalPath">物理路径，必填</param>
		/// <returns>状态码</returns>
		int CreateSite(SiteInfo siteinfo);

        /// <summary>
        /// 创建站点
        /// </summary>
        /// <param name="siteName">站点名，必填</param>
        /// <param name="httpPort">http端口，IIS6下必填</param>
        /// <param name="httpsPort">https端口</param>
        /// <param name="sslHash">ssl证书hash，指定httpsPort时必填</param>
        /// <param name="physicalPath">物理路径，必填</param>
        /// <returns>状态码</returns>
        int R_CreateSite(SiteInfo siteinfo);

        /// <summary>
        /// 编辑站点
        /// </summary>
        /// <param name="siteinfo"></param>
        /// <returns></returns>
        int SetSite(SiteInfo siteinfo);

		/// <summary>
		/// 移除站点
		/// </summary>
		/// <param name="siteName">站点名，必填</param>
		/// <returns>状态码</returns>
		int RemoveSite(string siteName);

		/// <summary>
		/// 创建应用程序池
		/// </summary>
		/// <param name="poolName">池名称，必填</param>
		/// <returns>状态码</returns>
		int CreateAppPool(string poolName);

		/// <summary>
		/// 移除应用程序池
		/// </summary>
		/// <param name="poolName">池名称，必填</param>
		/// <returns>状态码</returns>
		int RemoveAppPool(string poolName);

		/// <summary>
		/// 创建虚拟目录
		/// </summary>
		/// <param name="siteName">站点名，必填</param>
		/// <param name="virtualPath">虚拟路径，以/开头，目前只支持一级，必填</param>
		/// <param name="physicalPath">物理路径，必填</param>
		/// <param name="enableAllMimeTypes">是否允许所有类型文件的下载</param>
		/// <returns>状态码</returns>
		int CreateDir(string siteName, string virtualPath, string physicalPath, bool enableAllMimeTypes);

		/// <summary>
		/// 移除虚拟目录
		/// </summary>
		/// <param name="siteName">站点名，必填</param>
		/// <param name="virtualPath">虚拟路径，以/开头，目前只支持一级，必填</param>
		/// <returns>状态码</returns>
		int RemoveDir(string siteName, string virtualPath);

		/// <summary>
		/// 创建应用程序
		/// </summary>
		/// <param name="siteName">站点名，必填</param>
		/// <param name="virtualPath">虚拟路径，以/开头，目前只支持一级，必填</param>
		/// <param name="physicalPath">物理路径，必填</param>
		/// <param name="poolName">应用程序池名称</param>
		/// <param name="useSsl">是否只允许ssl访问</param>
		/// <returns>状态码</returns>
		int CreateApp(string siteName, string virtualPath, string physicalPath, string poolName, bool useSsl);

		/// <summary>
		/// 移除应用程序
		/// </summary>
		/// <param name="siteName">站点名，必填</param>
		/// <param name="virtualPath">虚拟路径，以/开头，目前只支持一级，必填</param>
		/// <returns>状态码</returns>
		int RemoveApp(string siteName, string virtualPath);

		/// <summary>
		/// 设置站点的证书
		/// </summary>
		/// <param name="siteName">站点名，必填</param>
		/// <param name="sslHash">ssl证书hash，必填</param>
		/// <returns>状态码</returns>
		int SetCertificate(string siteName, string sslHash);

		/// <summary>
		/// 设置站点端口
		/// </summary>
		/// <param name="siteName">站点名，必填</param>
		/// <param name="httpPort">http端口，IIS6下必填</param>
		/// <param name="httpsPort">https端口</param>
		/// <returns></returns>
		int SetPort(string siteName, int httpPort, int httpsPort);

        /// <summary>
        /// 获取站点信息
        /// </summary>
        /// <returns></returns>
        List<string> GetSiteInfo();
        /// <summary>
        /// 获取新站点信息
        /// </summary>
        /// <param name="newsitename"></param>
        /// <returns></returns>
        string GetNewSiteInfo(string newsitename);
        /// <summary>
        /// 获取ftp站点信息
        /// </summary>
        /// <param name="newsitename"></param>
        /// <returns></returns>
        List<string> GetFtpInfos();  
        /// <summary>
        /// 删除ftp站点
        /// </summary>
        /// <param name="ftpname"></param>
        /// <returns></returns>
        bool DeleteFtp(string ftpname);
        /// <summary>
        /// 获取站点路径
        /// </summary>
        /// <param name="sitename"></param>
        /// <returns></returns>
        string GetSitePath(string sitename);
        /// <summary>
        /// 获取所有站点名称
        /// </summary>
        /// <returns></returns>
        List<string> GetSiteNames();
        /// <summary>
        /// 删除FTP站点
        /// </summary>
        /// <returns></returns>
        bool DeleteFtp(IUtil util, string ftpname);
        /// <summary>
        /// 判断FTP是否存在
        /// </summary>
        /// <param name="ftpname"></param>
        /// <returns></returns>
        bool ExistsFtp(string ftpname);
        /// <summary>
        /// 创建FTP 
        /// </summary>
        /// <param name="ftpname"></param>
        /// <param name="ftppass"></param>
        /// <returns></returns>
        int CreateFtp(string ftpname, string ftppass, string path);

        int CreateFtp( bool rw, string ftpname, string ftppass, string path);


        /// <summary>
        /// 创建FTP
        /// </summary>
        /// <param name="ftpname"></param>
        /// <param name="ftppass"></param>
        /// <returns></returns>
        int CreateRewriteRule(string sitename, string sitepath);
        /// <summary>
        /// 删除用户-回滚
        /// </summary>
        /// <returns></returns>
        int DeleteSiteUsers();
        /// <summary>
        /// 301
        /// </summary>
        /// <returns></returns>
        int HttpRedirectAdd(string source_url,string target_url,string sitename);
	}
}
